<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');


class Login_check extends CI_Controller {

	function __construct()
	{
		parent::__construct();
	}

	public function index()
	{
		$this->load->model('user_m');
		$this->load->helper('url');
		$tmp=$this->user_m->user_SelectByUserName($_POST['loginuser']);
		if($tmp!=null){
				
			if($tmp[0]->password != md5($_POST['loginpass'])){
				echo "<script language='javascript' type='text/javascript'>";
				echo 'alert("密码错误!");';
				echo "</script>";
				redirect('index.php/?count=0','refresh');
			}else{
				setcookie('username',$tmp[0]->username,time()+60*60*12);
				setcookie('auth',$tmp[0]->auth,time()+60*60*12);
				echo "<script language='javascript' type='text/javascript'>";
				echo 'alert("登录成功!");';
				echo "</script>";
				redirect('?count=0','refresh');
			}
		}else{
			echo "<script language='javascript' type='text/javascript'>";
			echo 'alert("查无此用户!");';
			echo "</script>";
			redirect('?count=0','refresh');
		}
	}

}
?>